#include <iostream>

using namespace std;

void swap2num(int *a, int *b);
void swap2num(float *a, float *b);
int mi(int m, int n = 2);
void swap2num(int &a, int &b);

int main(void)
{
#if 0
	int n1, n2;
	float f1, f2;

	cin >> n1 >> n2;
	cin >> f1 >> f2;

	cout << "n1:" << n1 << ", n2:" << n2 << endl;
	cout << "f1:" << f1 << ", f2:" << f2 << endl;

	cout << "交换" << endl;
	swap2num(&n1, &n2);
	swap2num(&f1, &f2);

	cout << "n1:" << n1 << ", n2:" << n2 << endl;
	cout << "f1:" << f1 << ", f2:" << f2 << endl;
#endif

	int num = 10;
	int m = 10, n = 20;
	// q是m的引用, 永远是m的引用
	int &q = m;

	q = n; // m = n;

	cout << q << endl;
	cout << m << endl;

	cout << mi(num) << endl;
	cout << mi(num, 3) << endl;

	swap2num(m, n);
	cout << m << "," << n << endl;

	return 0;
}

void swap2num(int *a, int *b)
{
	int t;

	t = *a;
	*a = *b;
	*b = t;
}

void swap2num(float *a, float *b)
{
	float t;

	t = *a;
	*a = *b;
	*b = t;
}

int mi(int m, int n)
{
	int res = 1;

	while (n) {
		res *= m;
		n--;
	}

	return res;
}

// a b是用于交换的变量的引用，可以理解为别名
void swap2num(int &a, int &b)
{
	int t;
	t = a;
	a = b;
	b = t;
}



